import logging
import time
from selenium.webdriver.chrome import webdriver
from selenium.webdriver.common.by import By

from pages.dingdan import dolog


class JieSuansmzf():
    shangpin=(By.CSS_SELECTOR,'img[alt*="爱冕－白18K金钻石戒指"]')
    jiagou=(By.CSS_SELECTOR,'a[class*="btn_pink_138x32"]')
    shouye=(By.CSS_SELECTOR,'a[href*="index.php"]')
    jiesuan=(By.CSS_SELECTOR,'img[src*="themes/ecmoban_zsxn/images/checkout.gif"]')
    peisong=(By.CSS_SELECTOR,'input[name*="shipping"]')
    zhifu=(By.CSS_SELECTOR,'input[type*="radio"]')
    tijiao=(By.CSS_SELECTOR,'input[type*="image"]')
    def jieSuan(self):
        try:
            wd=webdriver.WebDriver()
            wd.get("http://192.168.88.132/user.php")
            wd.find_element_by_css_selector('input[name*="username"]').send_keys("123456")
            time.sleep(1)
            wd.find_element_by_css_selector('input[name*="password"]').send_keys('1373331kkkkAA')
            time.sleep(1)
            wd.find_element_by_css_selector('input[name*="submit"]').click()
            wd.find_element(*self.shouye).click()
            time.sleep(1)
            wd.find_element(*self.shangpin).click()
            time.sleep(1)
            wd.find_element(*self.jiagou).click()
            time.sleep(1)
            wd.find_element(*self.jiesuan).click()
            time.sleep(1)
            wd.find_element(*self.peisong).click()
            time.sleep(1)
            wd.find_element(*self.zhifu).click()
            time.sleep(1)
            wd.find_element(*self.tijiao).click()
            time.sleep(2)
        except Exception as e:
            dolog.error("捕获到异常")
            print(f"发生异常{e}")
        else:
            print("没有捕获到异常")
        finally:
            print("处理结束")

class JieSuandfzf():
    shangpin=(By.CSS_SELECTOR,'img[alt*="爱冕－白18K金钻石戒指"]')
    jiagou=(By.CSS_SELECTOR,'a[class*="btn_pink_138x32"]')
    shouye=(By.CSS_SELECTOR,'a[href*="index.php"]')
    jiesuan=(By.CSS_SELECTOR,'img[src*="themes/ecmoban_zsxn/images/checkout.gif"]')
    peisong=(By.CSS_SELECTOR,'input[name*="shipping"][value*="3"]')
    zhifu=(By.CSS_SELECTOR,'input[type*="radio"]')
    tijiao=(By.CSS_SELECTOR,'input[type*="image"]')
    def jieSuan(self):
        try:
            wd=webdriver.WebDriver()
            wd.get("http://192.168.88.132/user.php")
            wd.find_element_by_css_selector('input[name*="username"]').send_keys("123456")
            time.sleep(1)
            wd.find_element_by_css_selector('input[name*="password"]').send_keys('1373331kkkkAA')
            time.sleep(1)
            wd.find_element_by_css_selector('input[name*="submit"]').click()
            wd.find_element(*self.shouye).click()
            time.sleep(1)
            wd.find_element(*self.shangpin).click()
            time.sleep(1)
            wd.find_element(*self.jiagou).click()
            time.sleep(1)
            wd.find_element(*self.jiesuan).click()
            time.sleep(1)
            wd.find_element(*self.peisong).click()
            time.sleep(1)
            wd.find_element(*self.zhifu).click()
            time.sleep(1)
            wd.find_element(*self.tijiao).click()
            time.sleep(2)
        except Exception as e:
            dolog.error("捕获到异常")
            print(f"发生异常{e}")
        else:
            print("没有捕获到异常")
        finally:
            print("处理结束")
class JieSuansfzf():
    shangpin=(By.CSS_SELECTOR,'img[alt*="爱冕－白18K金钻石戒指"]')
    jiagou=(By.CSS_SELECTOR,'a[class*="btn_pink_138x32"]')
    shouye=(By.CSS_SELECTOR,'a[href*="index.php"]')
    jiesuan=(By.CSS_SELECTOR,'img[src*="themes/ecmoban_zsxn/images/checkout.gif"]')
    peisong=(By.CSS_SELECTOR,'input[name*="shipping"][value*="4"]')
    zhifu=(By.CSS_SELECTOR,'input[type*="radio"]')
    tijiao=(By.CSS_SELECTOR,'input[type*="image"]')
    def jieSuan(self):
        try:
            wd=webdriver.WebDriver()
            wd.get("http://192.168.88.132/user.php")
            wd.find_element_by_css_selector('input[name*="username"]').send_keys("123456")
            time.sleep(1)
            wd.find_element_by_css_selector('input[name*="password"]').send_keys('1373331kkkkAA')
            time.sleep(1)
            wd.find_element_by_css_selector('input[name*="submit"]').click()
            wd.find_element(*self.shouye).click()
            time.sleep(1)
            wd.find_element(*self.shangpin).click()
            time.sleep(1)
            wd.find_element(*self.jiagou).click()
            time.sleep(1)
            wd.find_element(*self.jiesuan).click()
            time.sleep(1)
            wd.find_element(*self.peisong).click()
            time.sleep(1)
            wd.find_element(*self.zhifu).click()
            time.sleep(1)
            wd.find_element(*self.tijiao).click()
            time.sleep(2)
        except Exception as e:
            dolog.error("捕获到异常")
            print(f"发生异常{e}")
        else:
            print("没有捕获到异常")
        finally:
            print("处理结束")


if __name__ == '__main__':
    j=JieSuan()
    j.jieSuan()




